﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using static System.Windows.Forms.VisualStyles.VisualStyleElement.TrayNotify;

namespace WindowsFormsApp
{
    public partial class FmMain : Form
    {
        public FmMain()
        {
            InitializeComponent();
        }
        int i = 0;
        /// <summary>
        /// 通用打开窗体方法
        /// </summary>
        /// <param name="fm"></param>
        public void OpenFm(System.Windows.Forms.Form fm)
        {
            try
            {
                foreach (DevExpress.XtraTabbedMdi.XtraMdiTabPage page in xtraTabbedMdiManager1.Pages)
                {
                    if (page.Text.ToString() == fm.Text.ToString())
                    {
                        i = i + 1;
                        page.Text = page.Text + i.ToString();
                        //fm.Dispose();
                        //xtraTabbedMdiManager1.SelectedPage = page;
                        //return;
                    }
                }
                fm.MdiParent = this;
                fm.Show();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }

        }

        private void 输入控件ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            WindowsForms.Comm.Control.FM.FmInputText fm =new WindowsForms.Comm.Control.FM.FmInputText();
            fm.ShowDialog();
            //OpenFm(fm);
        }

        private void listViewToolStripMenuItem_Click(object sender, EventArgs e)
        {
            WindowsForms.Comm.Control.FM.FmListView fm = new WindowsForms.Comm.Control.FM.FmListView();
            OpenFm(fm);

        }

        private void webViewToolStripMenuItem_Click(object sender, EventArgs e)
        {
            WindowsForms.Comm.Control.Web.FmWebView fm = new WindowsForms.Comm.Control.Web.FmWebView();
            OpenFm(fm);

        }
    }
}
